package com.atguigu.hellomp.test;

import io.minio.BucketExistsArgs;
import io.minio.MinioClient;
import io.minio.UploadObjectArgs;
import io.minio.errors.*;

import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;

public class T2 {

    public static void main(String[] args) throws ServerException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException {

        MinioClient minioClient = MinioClient.builder()
                .endpoint("http://192.168.222.88:9000")
                .credentials("minioadmin","minioadmin")
                .build();

        BucketExistsArgs bucketExistsArgs = BucketExistsArgs.builder()
                .bucket("lease-0715")
                .build();

        boolean b = minioClient.bucketExists(bucketExistsArgs);

        System.out.println("==============="+b+"==============");

        UploadObjectArgs uploadObjectArgs = UploadObjectArgs.builder()
                .bucket("lease-0715")
                .filename("d:/107.png")// 本地路径
                .object("a/107.png")// minio的bucket中的文件路径和名
                .build();
        minioClient.uploadObject(uploadObjectArgs);


    }
}
